package com.example.ad_project;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.nus.iss.ad.model.LoginUserInfo;

public class Dept_Activity extends BaseActivity implements OnClickListener{

	Button buttonDelegate,buttonApproveReq,buttonLogout;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dept);
		buttonDelegate=(Button)findViewById(R.id.btnDelegate);
		buttonDelegate.setOnClickListener(this);
		buttonApproveReq=(Button)findViewById(R.id.btnApproveReq);
		buttonApproveReq.setOnClickListener(this);
		buttonLogout=(Button)findViewById(R.id.btnLogOut);
		buttonLogout.setOnClickListener(this);
		
		buttonDelegate.setEnabled(
				!LoginUserInfo.currentUser.isDelegate()
				&&
				LoginUserInfo.currentUser.isDeptHead());
		
		buttonApproveReq.setEnabled(
				LoginUserInfo.currentUser.isDeptHead());

	}

	
	public void onClick(View v){
		
		Intent i;
		
		if(v==buttonDelegate) {
			i=new Intent(this,DelegateActivity.class);
			startActivity(i);
		}
			
		else if(v==buttonApproveReq){
			 i=new Intent(this,ApproveRequest.class);
			startActivity(i);
		}
			
		else if(v==buttonLogout){
			logOut();
		}
	}

}